from docx import Document

# 读取txt文件内容
def read_txt_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as f:
        content = f.read()
    return content

# 将txt内容写入Word文档
def write_to_word(content, output_file):
    doc = Document()
    doc.add_paragraph(content)
    doc.save(output_file)

# 示例用法
txt_file = 'input.txt'  # 输入的txt文件
output_file = 'output.docx'  # 输出的Word文件

content = read_txt_file(txt_file)
write_to_word(content, output_file)
